namespace QMVnSoft.ReportForms
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormKTH02CNViewer : FormReportViewer
    {
        private IContainer components;
        private LabelControl lblMa_Dt;
        private LabelControl lblMa_Dt_Du;
        private LabelControl lblNgay_Ct1;
        private LabelControl lblNgay_Ct2;
        private LabelControl lblTk;
        private TextSearch txtMa_Dt;
        private TextSearch txtMa_Nh_Dt;
        private TextDate txtNgay_Ct1;
        private TextDate txtNgay_Ct2;
        private TextControl txtTen_Dt;
        private TextControl txtTen_Nh_Dt;
        private TextControl txtTen_Tk;
        private TextSearch txtTk;

        public FormKTH02CNViewer()
        {
            this.InitializeComponent();
            this.txtNgay_Ct1.Value = AppInstance.StartWorkingDate;
            this.txtNgay_Ct2.Value = AppInstance.EndWorkingDate;
        }

        public FormKTH02CNViewer(object pd_Ngay_Ct1, object pd_Ngay_Ct2, object ps_Tk, object ps_Ma_Dt, object ps_Ma_Nh_Dt, object pi_Loai_Tte)
        {
            this.InitializeComponent();
            this.txtNgay_Ct1.Value = pd_Ngay_Ct1;
            this.txtNgay_Ct2.Value = pd_Ngay_Ct2;
            this.txtTk.Value = ps_Tk;
            this.txtMa_Dt.Value = ps_Ma_Dt;
            this.txtMa_Nh_Dt.Value = ps_Ma_Nh_Dt;
            this.txtTen_Tk.Value = this.txtTk.GetFieldData("Ten_Tk");
            this.txtTen_Dt.Value = this.txtMa_Dt.GetFieldData("Ten_Dt");
            this.txtTen_Nh_Dt.Value = this.txtMa_Nh_Dt.GetFieldData("Ten_Nh_Dt");
            this.OnMakeReport();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormKTH02CNViewer));
            this.txtTen_Tk = new QMVnSoft.Controls.TextControl();
            this.txtTk = new QMVnSoft.Controls.TextSearch();
            this.lblTk = new QMVnSoft.Controls.LabelControl();
            this.txtTen_Dt = new QMVnSoft.Controls.TextControl();
            this.txtMa_Dt = new QMVnSoft.Controls.TextSearch();
            this.lblMa_Dt = new QMVnSoft.Controls.LabelControl();
            this.lblMa_Dt_Du = new QMVnSoft.Controls.LabelControl();
            this.txtMa_Nh_Dt = new QMVnSoft.Controls.TextSearch();
            this.txtTen_Nh_Dt = new QMVnSoft.Controls.TextControl();
            this.txtNgay_Ct2 = new QMVnSoft.Controls.TextDate();
            this.lblNgay_Ct2 = new QMVnSoft.Controls.LabelControl();
            this.txtNgay_Ct1 = new QMVnSoft.Controls.TextDate();
            this.lblNgay_Ct1 = new QMVnSoft.Controls.LabelControl();
            this.rptContainer.Panel1.SuspendLayout();
            this.rptContainer.SuspendLayout();
            this.SuspendLayout();
            // 
            // rptContainer
            // 
            // 
            // rptContainer.Panel1
            // 
            this.rptContainer.Panel1.Controls.Add(this.txtNgay_Ct2);
            this.rptContainer.Panel1.Controls.Add(this.lblNgay_Ct2);
            this.rptContainer.Panel1.Controls.Add(this.txtNgay_Ct1);
            this.rptContainer.Panel1.Controls.Add(this.lblNgay_Ct1);
            this.rptContainer.Panel1.Controls.Add(this.txtTen_Nh_Dt);
            this.rptContainer.Panel1.Controls.Add(this.txtTen_Dt);
            this.rptContainer.Panel1.Controls.Add(this.txtMa_Nh_Dt);
            this.rptContainer.Panel1.Controls.Add(this.lblMa_Dt_Du);
            this.rptContainer.Panel1.Controls.Add(this.txtMa_Dt);
            this.rptContainer.Panel1.Controls.Add(this.lblMa_Dt);
            this.rptContainer.Panel1.Controls.Add(this.txtTen_Tk);
            this.rptContainer.Panel1.Controls.Add(this.txtTk);
            this.rptContainer.Panel1.Controls.Add(this.lblTk);
            this.rptContainer.Size = new System.Drawing.Size(794, 496);
            this.rptContainer.SplitterDistance = 88;
            // 
            // txtTen_Tk
            // 
            this.txtTen_Tk.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Tk.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Tk.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Tk.CheckTextSearched = false;
            this.txtTen_Tk.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Tk.Enabled = false;
            this.txtTen_Tk.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Tk.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Tk.Location = new System.Drawing.Point(214, 6);
            this.txtTen_Tk.Name = "txtTen_Tk";
            this.txtTen_Tk.OldValue = null;
            this.txtTen_Tk.Size = new System.Drawing.Size(458, 13);
            this.txtTen_Tk.TabIndex = 1;
            this.txtTen_Tk.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Tk.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Tk.Value = ((object)(resources.GetObject("txtTen_Tk.Value")));
            // 
            // txtTk
            // 
            this.txtTk.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtTk.CheckTextSearched = false;
            this.txtTk.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtTk.FieldDisplay = "Ten_Tk";
            this.txtTk.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTk.FoundIsValid = true;
            this.txtTk.Location = new System.Drawing.Point(108, 3);
            this.txtTk.MaxLength = 32;
            this.txtTk.Name = "txtTk";
            this.txtTk.OldValue = null;
            this.txtTk.Size = new System.Drawing.Size(100, 20);
            this.txtTk.TabIndex = 0;
            this.txtTk.TableName = "DMTK";
            this.txtTk.TextDisplay = this.txtTen_Tk;
            this.txtTk.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtTk.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtTk.Value = ((object)(resources.GetObject("txtTk.Value")));
            // 
            // lblTk
            // 
            this.lblTk.AutoSize = true;
            this.lblTk.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTk.Location = new System.Drawing.Point(12, 6);
            this.lblTk.Name = "lblTk";
            this.lblTk.Size = new System.Drawing.Size(53, 14);
            this.lblTk.TabIndex = 87;
            this.lblTk.Text = "Tài khoản";
            // 
            // txtTen_Dt
            // 
            this.txtTen_Dt.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Dt.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Dt.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Dt.CheckTextSearched = false;
            this.txtTen_Dt.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Dt.Enabled = false;
            this.txtTen_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Dt.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Dt.Location = new System.Drawing.Point(214, 49);
            this.txtTen_Dt.Name = "txtTen_Dt";
            this.txtTen_Dt.OldValue = null;
            this.txtTen_Dt.Size = new System.Drawing.Size(458, 13);
            this.txtTen_Dt.TabIndex = 3;
            this.txtTen_Dt.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Dt.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Dt.Value = ((object)(resources.GetObject("txtTen_Dt.Value")));
            // 
            // txtMa_Dt
            // 
            this.txtMa_Dt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Dt.CheckTextSearched = false;
            this.txtMa_Dt.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Dt.EmptyIsValid = true;
            this.txtMa_Dt.FieldDisplay = "Ten_Dt";
            this.txtMa_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Dt.FoundIsValid = true;
            this.txtMa_Dt.Location = new System.Drawing.Point(108, 45);
            this.txtMa_Dt.MaxLength = 32;
            this.txtMa_Dt.Name = "txtMa_Dt";
            this.txtMa_Dt.OldValue = null;
            this.txtMa_Dt.Size = new System.Drawing.Size(100, 20);
            this.txtMa_Dt.TabIndex = 2;
            this.txtMa_Dt.TableName = "DMDT";
            this.txtMa_Dt.TextDisplay = this.txtTen_Dt;
            this.txtMa_Dt.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Dt.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Dt.Value = ((object)(resources.GetObject("txtMa_Dt.Value")));
            // 
            // lblMa_Dt
            // 
            this.lblMa_Dt.AutoSize = true;
            this.lblMa_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Dt.Location = new System.Drawing.Point(12, 48);
            this.lblMa_Dt.Name = "lblMa_Dt";
            this.lblMa_Dt.Size = new System.Drawing.Size(55, 14);
            this.lblMa_Dt.TabIndex = 94;
            this.lblMa_Dt.Text = "Đối tượng";
            // 
            // lblMa_Dt_Du
            // 
            this.lblMa_Dt_Du.AutoSize = true;
            this.lblMa_Dt_Du.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Dt_Du.Location = new System.Drawing.Point(12, 27);
            this.lblMa_Dt_Du.Name = "lblMa_Dt_Du";
            this.lblMa_Dt_Du.Size = new System.Drawing.Size(83, 14);
            this.lblMa_Dt_Du.TabIndex = 94;
            this.lblMa_Dt_Du.Text = "Nhóm đối tượng";
            // 
            // txtMa_Nh_Dt
            // 
            this.txtMa_Nh_Dt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Nh_Dt.CheckTextSearched = false;
            this.txtMa_Nh_Dt.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Nh_Dt.EmptyIsValid = true;
            this.txtMa_Nh_Dt.FieldDisplay = "Ten_Nh_Dt";
            this.txtMa_Nh_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Nh_Dt.FoundIsValid = true;
            this.txtMa_Nh_Dt.Location = new System.Drawing.Point(108, 24);
            this.txtMa_Nh_Dt.MaxLength = 32;
            this.txtMa_Nh_Dt.Name = "txtMa_Nh_Dt";
            this.txtMa_Nh_Dt.OldValue = null;
            this.txtMa_Nh_Dt.Size = new System.Drawing.Size(100, 20);
            this.txtMa_Nh_Dt.TabIndex = 1;
            this.txtMa_Nh_Dt.TableName = "DMNHDT";
            this.txtMa_Nh_Dt.TextDisplay = this.txtTen_Nh_Dt;
            this.txtMa_Nh_Dt.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Nh_Dt.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Nh_Dt.Value = ((object)(resources.GetObject("txtMa_Nh_Dt.Value")));
            // 
            // txtTen_Nh_Dt
            // 
            this.txtTen_Nh_Dt.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Nh_Dt.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Nh_Dt.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Nh_Dt.CheckTextSearched = false;
            this.txtTen_Nh_Dt.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Nh_Dt.Enabled = false;
            this.txtTen_Nh_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Nh_Dt.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Nh_Dt.Location = new System.Drawing.Point(214, 28);
            this.txtTen_Nh_Dt.Name = "txtTen_Nh_Dt";
            this.txtTen_Nh_Dt.OldValue = null;
            this.txtTen_Nh_Dt.Size = new System.Drawing.Size(458, 13);
            this.txtTen_Nh_Dt.TabIndex = 5;
            this.txtTen_Nh_Dt.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Nh_Dt.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Nh_Dt.Value = ((object)(resources.GetObject("txtTen_Nh_Dt.Value")));
            // 
            // txtNgay_Ct2
            // 
            this.txtNgay_Ct2.DateTimeFormat  = QMVnSoft.Controls.TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ct2.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNgay_Ct2.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite;
            this.txtNgay_Ct2.Location = new System.Drawing.Point(316, 66);
            this.txtNgay_Ct2.Mask = "00/00/0000";
            this.txtNgay_Ct2.Name = "txtNgay_Ct2";
            this.txtNgay_Ct2.OldValue = null;
            this.txtNgay_Ct2.Size = new System.Drawing.Size(100, 20);
            this.txtNgay_Ct2.TabIndex = 4;
            this.txtNgay_Ct2.Value = ((object)(resources.GetObject("txtNgay_Ct2.Value")));
            // 
            // lblNgay_Ct2
            // 
            this.lblNgay_Ct2.AutoSize = true;
            this.lblNgay_Ct2.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNgay_Ct2.Location = new System.Drawing.Point(256, 69);
            this.lblNgay_Ct2.Name = "lblNgay_Ct2";
            this.lblNgay_Ct2.Size = new System.Drawing.Size(54, 14);
            this.lblNgay_Ct2.TabIndex = 97;
            this.lblNgay_Ct2.Text = "Đến ngày";
            // 
            // txtNgay_Ct1
            // 
            this.txtNgay_Ct1.DateTimeFormat  = QMVnSoft.Controls.TextDate.DateTimeFormatType.Date;
            this.txtNgay_Ct1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNgay_Ct1.InsertKeyMode = System.Windows.Forms.InsertKeyMode.Overwrite;
            this.txtNgay_Ct1.Location = new System.Drawing.Point(108, 66);
            this.txtNgay_Ct1.Mask = "00/00/0000";
            this.txtNgay_Ct1.Name = "txtNgay_Ct1";
            this.txtNgay_Ct1.OldValue = null;
            this.txtNgay_Ct1.Size = new System.Drawing.Size(100, 20);
            this.txtNgay_Ct1.TabIndex = 3;
            this.txtNgay_Ct1.Value = ((object)(resources.GetObject("txtNgay_Ct1.Value")));
            // 
            // lblNgay_Ct1
            // 
            this.lblNgay_Ct1.AutoSize = true;
            this.lblNgay_Ct1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNgay_Ct1.Location = new System.Drawing.Point(12, 69);
            this.lblNgay_Ct1.Name = "lblNgay_Ct1";
            this.lblNgay_Ct1.Size = new System.Drawing.Size(47, 14);
            this.lblNgay_Ct1.TabIndex = 98;
            this.lblNgay_Ct1.Text = "Từ ngày";
            // 
            // FormKTH02CNViewer
            // 
            this.ClientSize = new System.Drawing.Size(794, 528);
            this.Name = "FormKTH02CNViewer";
            this.rptContainer.Panel1.ResumeLayout(false);
            this.rptContainer.Panel1.PerformLayout();
            this.rptContainer.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        protected override void OnGenerateColumns()
        {
            if (base.CurrencyIndex == 0)
            {
                object[][] objArray = new object[8][];
                object[] objArray2 = new object[4];
                objArray2[0] = "Ma_Dt";
                objArray2[1] = "Mã đối tượng ";
                objArray2[2] = "C";
                objArray[0] = objArray2;
                object[] objArray3 = new object[4];
                objArray3[0] = "Ten_Dt";
                objArray3[1] = "Tên đối tượng";
                objArray3[2] = "C";
                objArray[1] = objArray3;
                objArray[2] = new object[] { "Du_No1", "Dư nợ đầu", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[3] = new object[] { "Du_Co1", "Dư có đầu", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[4] = new object[] { "Ps_No", "Phát sinh nợ", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[5] = new object[] { "Ps_Co", "Phát sinh có", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[6] = new object[] { "Du_No2", "Dư nợ cuối", "N", AppInstance.TextNumericFormat.LocalAmount };
                objArray[7] = new object[] { "Du_Co2", "Dư có cuối", "N", AppInstance.TextNumericFormat.LocalAmount };
                base.LocalColNames = objArray;
                base.OnGenerateColumns();
            }
            else
            {
                object[][] objArray10 = new object[8][];
                object[] objArray11 = new object[4];
                objArray11[0] = "Ma_Dt";
                objArray11[1] = "Mã đối tượng ";
                objArray11[2] = "C";
                objArray10[0] = objArray11;
                object[] objArray12 = new object[4];
                objArray12[0] = "Ten_Dt";
                objArray12[1] = "Tên đối tượng";
                objArray12[2] = "C";
                objArray10[1] = objArray12;
                objArray10[2] = new object[] { "Du_No_Nt1", "Dư nợ đầu", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[3] = new object[] { "Du_Co_Nt1", "Dư có đầu", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[4] = new object[] { "Ps_No_Nt", "Ps nợ", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[5] = new object[] { "Ps_Co_Nt", "Ps có", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[6] = new object[] { "Du_No_Nt2", "Dư nợ cuối", "N", AppInstance.TextNumericFormat.ForeignAmount };
                objArray10[7] = new object[] { "Du_Co_Nt2", "Dư có cuối", "N", AppInstance.TextNumericFormat.ForeignAmount };
                base.ForeignColNames = objArray10;
                base.OnGenerateColumns();
            }
        }

        protected override void OnMakeReport()
        {
            AppInstance.StartWorkingDate = (DateTime) this.txtNgay_Ct1.Value;
            AppInstance.EndWorkingDate = (DateTime) this.txtNgay_Ct2.Value;
            base.LocalTable = new ReportDataAccess().KTH02_Get(AppInstance.Subsidiaries, this.txtNgay_Ct1.Value, this.txtNgay_Ct2.Value, this.txtTk.Value, this.txtMa_Dt.Value, this.txtMa_Nh_Dt.Value, AppInstance.DefLanguage);
            base.OnMakeReport();
        }

        protected override void OnSendParameters()
        {
            base.StimulReport["Ngay"] = "Từ ngày " + string.Format("{0:dd/MM/yyyy}", this.txtNgay_Ct1.Value) + " đến ngày " + string.Format("{0:dd/MM/yyyy}", this.txtNgay_Ct2.Value);
            if (string.IsNullOrEmpty(this.txtTk.Value.ToString()))
            {
                base.StimulReport["TaiKhoan"] = "";
            }
            else
            {
                base.StimulReport["TaiKhoan"] = string.Concat(new object[] { "Tài khoản: ", this.txtTen_Tk.Value, " (", this.txtTk.Value, ")" });
            }
            if (string.IsNullOrEmpty(this.txtMa_Dt.Value.ToString()))
            {
                base.StimulReport["DoiTuong"] = "";
            }
            else
            {
                base.StimulReport["DoiTuong"] = string.Concat(new object[] { "Đối tượng: ", this.txtTen_Dt.Value, " (", this.txtMa_Dt.Value, ")" });
            }
        }

        protected override void OnShowDetail()
        {
            object obj2 = ((DataRowView) base.DataGridBrowser.CurrentRow.DataBoundItem).Row["Ma_Dt"];
            if (!string.IsNullOrEmpty(obj2.ToString()))
            {
                FormKCT04CNViewer viewer = new FormKCT04CNViewer(this.txtNgay_Ct1.Value, this.txtNgay_Ct2.Value, this.txtTk.Value, obj2, this.txtMa_Nh_Dt.Value, base.CurrencyIndex);
                viewer.TitleText = "Sổ chi tiết công nợ phải thu";
                viewer.ReportTitle = "Sổ chi tiết công nợ phải thu";
                viewer.ReportFile = "KCT04";
                viewer.Show();
            }
        }
    }
}

